<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;
use App\Http\Controllers\Auth\userC;
use App\Http\Controllers\Auth\UsrGroupController;
use App\Http\Controllers\baseinfo\EmployeeController;
use App\Http\Controllers\baseinfo\DeptController;
use App\Http\Controllers\baseinfo\ChannelController;
use App\Http\Controllers\functions\ComUiSetController;
use App\Http\Controllers\Auth\LogfileController;
use App\Http\Controllers\Auth\UseLogController;
use App\Http\Controllers\Auth\UserapplyController;
use App\Http\Controllers\functions\CustomMenuController;
use App\Http\Controllers\functions\GrantfunctionController;
use App\Http\Controllers\UploadController;
use App\Http\Controllers\homeController;
use App\Http\Controllers\TesttabController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
*/

Route::get('/', function () {
    return view('welcome');
});
//文件上传下载
Route::post('/uploadfile', [UploadController::class, 'uploadfile']);
Route::get('/removefile', [UploadController::class, 'removefile']);
//用户管理
Route::match(['get', 'post'], '/login', [userC::class, 'login']);//登录
Route::match(['get', 'post'], '/logout', [userC::class, 'logout'])->middleware('auth:api');//退出登录
Route::match(['get', 'post'], '/register', [userC::class, 'register']);//注册
Route::match(['get', 'post'], '/user/find', [userC::class, 'getUserList'])->middleware('auth:api');//获取用户列表
Route::match(['get', 'post'], '/user/save', [userC::class, 'changeUserInfo'])->middleware('auth:api');//修改用户信息
Route::match(['get', 'post'], '/user/delete', [userC::class, 'delete'])->middleware('auth:api');//删除用户
Route::match(['get', 'post'], '/user/SetUserInfo', [userC::class, 'SetUserInfo'])->middleware('auth:api');//启用/停用用户
Route::match(['get', 'post'], '/user/Setchannel', [userC::class, 'Setchannel'])->middleware('auth:api');//批量修改归属组织
Route::match(['get', 'post'], '/user/changePassword', [userC::class, 'changePassword'])->middleware('auth:api');//修改密码
//人事档案
Route::match(['get', 'post'], '/employee/find', [EmployeeController::class, 'find'])->middleware('auth:api');//查询
Route::match(['get', 'post'], '/employee/finddetail', [EmployeeController::class, 'finddetail'])->middleware('auth:api');//查询详细
Route::match(['get', 'post'], '/employee/save', [EmployeeController::class, 'save'])->middleware('auth:api');//保存
Route::match(['get', 'post'], '/employee/delete', [EmployeeController::class, 'delete'])->middleware('auth:api');//删除
Route::match(['post'], '/employee/excelimport', [EmployeeController::class, 'excelimport'])->middleware('auth:api');//导入
//部门档案
Route::match(['get', 'post'], '/dept/find', [DeptController::class, 'find'])->middleware('auth:api');//查询
Route::match(['get', 'post'], '/dept/save', [DeptController::class, 'save'])->middleware('auth:api');//保存
Route::match(['get', 'post'], '/dept/delete', [DeptController::class, 'delete'])->middleware('auth:api');//删除
//组织机构
Route::match(['get', 'post'], '/channel/find', [ChannelController::class, 'find'])->middleware('auth:api');//查询
Route::match(['get', 'post'], '/channel/save', [ChannelController::class, 'save'])->middleware('auth:api');//保存
Route::match(['get', 'post'], '/channel/delete', [ChannelController::class, 'delete'])->middleware('auth:api');//删除
Route::match(['get', 'post'], '/channel/loadchannel', [ChannelController::class, 'loadchannel'])->middleware('auth:api');//首页查询

//角色档案
Route::match(['get', 'post'], '/UsrGroup/find', [UsrGroupController::class, 'find'])->middleware('auth:api');//查询
Route::match(['get', 'post'], '/UsrGroup/save', [UsrGroupController::class, 'save'])->middleware('auth:api');//保存
Route::match(['get', 'post'], '/UsrGroup/delete', [UsrGroupController::class, 'delete'])->middleware('auth:api');//删除
Route::match(['get', 'post'], '/UsrGroup/excelimport', [UsrGroupController::class, 'excelimport'])->middleware('auth:api');//导入
//自定义格式配置
Route::match(['get', 'post'], '/ComUiSet/find', [ComUiSetController::class, 'find'])->middleware('auth:api');//查询
Route::match(['get', 'post'], '/ComUiSet/save', [ComUiSetController::class, 'save'])->middleware('auth:api');//保存
Route::match(['get', 'post'], '/ComUiSet/delete', [ComUiSetController::class, 'delete'])->middleware('auth:api');//删除
//登录日志
Route::match(['get', 'post'], '/Logfile/find', [LogfileController::class, 'find'])->middleware('auth:api');//查询
//操作日志
Route::match(['get', 'post'], '/UseLog/find', [UseLogController::class, 'find'])->middleware('auth:api');//查询
//用户审批
Route::match(['get', 'post'], '/Userapply/find', [UserapplyController::class, 'find'])->middleware('auth:api');//查询
Route::match(['get', 'post'], '/Userapply/handle', [UserapplyController::class, 'handle'])->middleware('auth:api');//审批
Route::match(['get', 'post'], '/Userapply/delete', [UserapplyController::class, 'delete'])->middleware('auth:api');//删除
//自定义菜单
Route::match(['get', 'post'], '/CustomMenu/LoadMenu', [CustomMenuController::class, 'LoadMenu'])->middleware('auth:api');//首页获取菜单
Route::match(['get', 'post'], '/CustomMenu/findlist', [CustomMenuController::class, 'findlist'])->middleware('auth:api');//查询列表
Route::match(['get', 'post'], '/CustomMenu/finddetail', [CustomMenuController::class, 'finddetail'])->middleware('auth:api');//查询详情
Route::match(['get', 'post'], '/CustomMenu/save', [CustomMenuController::class, 'save'])->middleware('auth:api');//保存
Route::match(['get', 'post'], '/CustomMenu/enablehandle', [CustomMenuController::class, 'enablehandle'])->middleware('auth:api');//启用|禁用
Route::match(['get', 'post'], '/CustomMenu/delete', [CustomMenuController::class, 'delete'])->middleware('auth:api');//删除
//权限管理
Route::match(['get', 'post'], '/Grantfunction/loadgrant', [GrantfunctionController::class, 'loadgrant'])->middleware('auth:api');//查询当前人权限
Route::match(['get', 'post'], '/Grantfunction/findlist', [GrantfunctionController::class, 'findlist'])->middleware('auth:api');//查询列表
Route::match(['get', 'post'], '/Grantfunction/save', [GrantfunctionController::class, 'save'])->middleware('auth:api');//保存

//其它功能用法示例
Route::match(['get', 'post'], '/missiondispatch', [homeController::class, 'missiondispatch']);//redis任务分发
Route::match(['get', 'post'], '/pay', [homeController::class, 'pay']);//契约的测试任务分发

//测试分库分表大数据
Route::match(['get', 'post'], '/Testtab/generate', [TesttabController::class, 'generate'])->middleware('auth:api');//生成数据
Route::match(['get', 'post'], '/Testtab/find', [TesttabController::class, 'find'])->middleware('auth:api');//查询
Route::match(['get', 'post'], '/Testtab/save', [TesttabController::class, 'save'])->middleware('auth:api');//保存
Route::match(['get', 'post'], '/Testtab/delete', [TesttabController::class, 'delete'])->middleware('auth:api');//删除

Route::any('{any}', function (Request $request) {
    //所有api的请求都是api开头
    //所有游览器页面的路由都是web开头 
    //其它开头一律不认
    $path = $request->path();
    $path = substr($path, 0, 3);
    if ($path == 'app') {
        return response()->json(['code' => 0, 'msg' => '不存在方法或请求方式有误，请检查!']);
    } else if ($path == 'web' || $path == '/') {
        return view('welcome');
    } else {
        return response()->json(['code' => 0, 'msg' => '无效API请求1' . $path]);
    }
})->where('any', '.*');

